//
//  KWMMainVC.m
//
//  Created by kevin on 3/14/15.
//  Copyright (c) 2015 kollway. All rights reserved.
//

#import "KWMMainVC.h"
#import "AppDelegate.h"
#import "KWMStringUtil.h"
#import "KWMImageUtil.h"

@interface KWMMainVC ()

@end

@implementation KWMMainVC{
     NSMutableArray *allFriendsArray;
}


+(NSString *)kwmTag{
    return @"MainVC";
}

-(void)awakeFromNib{
    [super awakeFromNib];
    self.title = @"首页";
}

- (void)viewDidLoad {
    [super viewDidLoad];
    [self initView];
}

-(void) initView{
    [self loadTabBar];

}

- (void)loadTabBar {
    
    //UITabBar样式
    UITabBar *tabBar = self.tabBar;

    tabBar.backgroundImage = [KWMImageUtil createColorImage:[UIColor sam_colorWithHex:@"#4BB87D"]];
    tabBar.contentMode = UIViewContentModeScaleAspectFit;
    
//    UIImage *slImage = [KWMImageUtil createColorImage:[UIColor sam_colorWithHex:@"#FFFFFF"]];
        UIImage *slImage = [UIImage imageNamed:@"bg_white"];
    [tabBar setSelectionIndicatorImage:slImage];
    
    
    [UITabBarItem.appearance setTitleTextAttributes:@{
                                                      NSForegroundColorAttributeName : [UIColor sam_colorWithHex:@"#FF3333"], NSFontAttributeName :[UIFont systemFontOfSize:12.0f]} forState:UIControlStateSelected];
    
    [UITabBarItem.appearance setTitleTextAttributes:@{
                                                      NSForegroundColorAttributeName : [UIColor whiteColor],
                                                            NSFontAttributeName :[UIFont systemFontOfSize:12.0f]} forState:UIControlStateNormal];
    
    UITabBarItem *tabBarItem1 = (tabBar.items)[0];
    UITabBarItem *tabBarItem2 = (tabBar.items)[1];
    UITabBarItem *tabBarItem3 = (tabBar.items)[2];
    UITabBarItem *tabBarItem4 = (tabBar.items)[3];
    UITabBarItem *tabBarItem5 = (tabBar.items)[4];
    
    UIImage *image = [[UIImage imageNamed:@"ic_tab_found"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    tabBarItem1.image = image;
    image = [[UIImage imageNamed:@"ic_tab_found_hover"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    tabBarItem1.selectedImage = image;
    
    UIImage *image1 = [[UIImage imageNamed:@"ic_tab_msg"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    tabBarItem2.image = image1;
    image1 = [[UIImage imageNamed:@"ic_tab_msg_hover"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    tabBarItem2.selectedImage = image1;
    
    UIImage *image2 = [[UIImage imageNamed:@"ic_tab_add"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    tabBarItem3.image = image2;
    image2 = [[UIImage imageNamed:@"ic_tab_add_hover"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    tabBarItem3.selectedImage = image2;
    
    UIImage *image3 = [[UIImage imageNamed:@"ic_tab_friend"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    tabBarItem4.image = image3;
    image3 = [[UIImage imageNamed:@"ic_tab_friend_hover"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    tabBarItem4.selectedImage = image3;
    
    UIImage *image4 = [[UIImage imageNamed:@"ic_tab_psn"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    tabBarItem5.image = image4;
    image4 = [[UIImage imageNamed:@"ic_tab_psn_hover"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    tabBarItem5.selectedImage = image4;
    

    //文字与图标，微调
    for (int i = 0; i <= 4; i++) {
        UITabBarItem *item = tabBar.items[i];
        CGFloat horizontalOffset = i == 1 ? 2 : 0;
        [item setTitlePositionAdjustment:UIOffsetMake(0, -1)];
        [item setImageInsets:UIEdgeInsetsMake(-3, horizontalOffset, 3, -horizontalOffset)];
    }
}


@end
